<?php


namespace Admin\Controller;


use Common\Controller\BaseController;
use Common\Model\BrandModel;

class BrandController extends BaseController
{

    public function index(){
        $data=m('brand')->select();

        $this->assign('data',$data);

        $this->display();
    }



    public function add(){
        if (IS_POST){
            $data=I('post.');
           $this->store(new BrandModel(),$data,u('admin/Brand/index'));
        }
        $this->display();
    }

    public  function set(){
        $bid=I('get.bid');

        if (IS_POST){
            $data=I('post.');
            if ($bid){
                $data['bid']=$bid;
            }

            $this->store(new BrandModel(),$data,u('admin/Brand/index'));
        }

        $oldData=m('brand')->find($bid);
//
        $this->assign('oldData',$oldData);



        $this->display();

    }
    public function del(){

        $bid=I('get.bid');
        (new BrandModel())->where("bid={$bid}")->delete();
        $this->success('操作成功',u('admin/brand/index'));
    }
}